package com.blb.goods_service.controller;

import com.blb.goods_service.entity.Goods;
import com.blb.goods_service.entity.JsonResult;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/test")
public class RestTestController {

    @GetMapping
    public JsonResult testGet(){
        return new JsonResult(200L,"查询所有数据");
    }

    @GetMapping("{id}")
    public JsonResult testGetOne(@PathVariable("id")Long id){
        return new JsonResult(200L,"查询单条数据"+id);
    }

    @PostMapping("post")
    public JsonResult testPost(@RequestBody Goods goods){
        System.out.println("添加：" + goods);
        return new JsonResult(200L,"添加成功");
    }

    @PostMapping("post2")
    public JsonResult testPost2(Goods goods){
        System.out.println("添加 -POST：" + goods);
        return new JsonResult(200L,"添加成功");
    }

    @PostMapping("login")
    public JsonResult login(@RequestParam String username,@RequestParam String password){
        System.out.println(username+","+password);
        return new JsonResult(200L,"登录成功");
    }

    @PutMapping
    public JsonResult testPut(@RequestBody Goods goods){
        System.out.println("更新：" + goods);
        return new JsonResult(200L,"更新成功");
    }

    @DeleteMapping("{id}")
    public JsonResult testPost(@PathVariable("id")Long id){
        System.out.println("删除：" + id);
        return new JsonResult(200L,"删除成功");
    }
}
